package com.lhd.qd.common.base;

import org.springframework.http.ResponseEntity;

public class BaseController {

    protected static ResponseEntity<ApiResult> success() {
        return ResponseEntityBuilder.ok("");
    }

    protected static <T> ResponseEntity<ApiResult<T>> success(T data) {
        return ResponseEntityBuilder.ok(data);
    }

    protected static ResponseEntity<ApiResult> error(String msg) {
        return ResponseEntityBuilder.badRequest(msg);
    }

    protected static ResponseEntity<ApiResult> successOrFail(Boolean flag) {
        return flag ? success() : ResponseEntityBuilder.badRequest("操作失败，数据可能已被修改或删除");
    }
}
